package com.example.orderform.config;

import io.swagger.annotations.SwaggerDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2  //开启swagger框架能力支撑
public class SwaggerConfig {

    @Bean
    public Docket getSwagger()
    {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiinfo())
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
                .paths(PathSelectors.any())
                .build();

    }

    private ApiInfo getApiinfo(){
        return new ApiInfoBuilder()
                .title("订单中心")
                .description("这是订单中心接口详细信息")
                .version("v2.0.0")
                .contact(new Contact("dm","www.dm.com","2088572636@qq.com"))
                .build();
    }


}
